﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Trackr.Core.Entities;

namespace Trackr.GUI.Views
{
	/// <summary>
	/// Interaction logic for TimeItem.xaml
	/// </summary>
	public partial class TimeItemView : UserControl
	{
	    public readonly string TaskDescription;
	    public readonly TimeSpan TaskDuration;

	    public TimeItemView()
		{
			this.InitializeComponent();
		}

		public TimeItemView(string taskDescription, TimeSpan taskDuration)
			: this()
		{
		    TaskDescription = taskDescription;
		    TaskDuration = taskDuration;
		    this.Task.Content = taskDescription;
            this.Task.ToolTip = taskDescription;
            this.Duration.Content = taskDuration.ToString(@"hh\:mm\:ss");
		}

		public TimeItemView(TimeItem timeItem): this()
		{
		    this.DataContext = timeItem;
            //TaskDescription = timeItem.Task;
            //TaskDuration = timeItem.GetDuration();
            //this.Duration.Content = TaskDuration.ToString(@"hh\:mm\:ss");
		}

	    public void CopyTaskText(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
	    {
            ListBox lb = (ListBox)(sender);
            var selected = lb.SelectedItem;
            if (selected != null) Clipboard.SetText(selected.ToString());
	    }
        private void CtrlCCopyCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
	}
}